﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Interop.Word;

namespace WFL.Office.Word
{
    public class WordBookmarks : IEnumerable<WordBookmark>
    {
        public WordBookmark this[int index]
        {
            get { return new WordBookmark(_bookmarks[index]) { Document = Document }; }
        }

        public WordBookmark this[string index]
        {
            get { return new WordBookmark(_bookmarks[index]) { Document = Document }; }
        }

        public int Count
        {
            get { return _bookmarks.Count; }
        }

        private Bookmarks _bookmarks;

        public WordDocument Document
        {
            get;
            internal set;
        }

        internal WordBookmarks(Bookmarks bookmarks)
        {
            _bookmarks = bookmarks;
        }


        #region IEnumerable<WordBookmark> 成员

        public IEnumerator<WordBookmark> GetEnumerator()
        {
            foreach (Bookmark bookmark in _bookmarks)
            {
                yield return new WordBookmark(bookmark) { Document = Document };
            }
        }

        #endregion

        #region IEnumerable 成员

        IEnumerator IEnumerable.GetEnumerator()
        {
            foreach (Bookmark bookmark in _bookmarks)
            {
                yield return new WordBookmark(bookmark) { Document = Document };
            }
        }

        #endregion

    }
}
